﻿using AnesSystem.Controls;
using AnesSystem.Controls.Operation.CQ.CQFY;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AnesSystem.ViewModels.Operation.CQ.CQTL
{
    public class AnesRecordCtrlViewModel : AnesSystem.ViewModels.AnesRecordCtrlViewModel
    {
        #region Variables

        #endregion


        #region Constructor
        public AnesRecordCtrlViewModel()
        {

        }
        #endregion


        #region Properties

        #endregion


        #region 依赖属性


        #endregion


        #region Event


        #endregion


        #region PrivateMethods


        #endregion


        #region Public/ProtectedMethods

        public override void InitData()
        {
            if (!DataManager.Instance.PatientLinkCache.ContainsKey(DataManager.Instance.CurrentPatientLink.Id))
            {
                AnesRecordItems.Clear();
                _anesRecordCtrlViewModels.Clear();
                _totalPages = DataManager.Instance.CurrentPatientLink.Status.TotalPage;
                for (int page = 1; page <= _totalPages; page++)
                {
                    AnesRecordItemCtrlViewModel viewmode = new AnesRecordItemCtrlViewModel(page);
                    AnesRecordItems.Add(viewmode);
                    AnesRecordCtrlViewModels.Add(page, viewmode);
                }
                LoadData();
            }
            else
            {
                BaseTableControl ctrl = DataManager.Instance.AnesRecordCtrl;
                if (ctrl.IsNewCreate)
                {
                    AnesRecordItems.Clear();
                    _anesRecordCtrlViewModels.Clear();
                    _totalPages = DataManager.Instance.CurrentPatientLink.Status.TotalPage;
                    for (int page = 1; page <= _totalPages; page++)
                    {
                        AnesRecordItemCtrlViewModel viewmode = new AnesRecordItemCtrlViewModel(page);
                        AnesRecordItems.Add(viewmode);
                        AnesRecordCtrlViewModels.Add(page, viewmode);
                    }
                    ctrl.IsNewCreate = false;

                    LoadData();
                }
            }
        }

        #endregion


        #region EventHandlers


        #endregion
    }
}
